// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#ifndef STDAFX_H
#define STDAFX_H

#ifndef NDEBUG
    //#define NDEBUG  //uncomment to shut stuff up (assertions, high verbosity)
#endif

#ifndef CAVITY_BUILD_WITH_BOOST
    #define CAVITY_BUILD_WITH_BOOST //comment to buid without any boost libraries
#endif

#ifdef CAVITY_BUILD_WITH_BOOST

    #ifndef CAVITY_MULTITHREADING_AVAILABLE
        #define CAVITY_MULTITHREADING_AVAILABLE //comment to build without boost::thread
    #endif

    #ifndef CAVITY_USE_BOOST_RANDOM
        #define CAVITY_USE_BOOST_RANDOM // . . . boost::random
    #endif

    #ifndef CAVITY_MODES_VECTOR_USE_PTR_VECTOR
        #define CAVITY_MODES_VECTOR_USE_PTR_VECTOR // . . . boost::ptr_vector
    #endif

    #ifdef CAVITY_MULTITHREADING_AVAILABLE
        #include <boost/version.hpp>
        #if (BOOST_VERSION / 100000) >= 1 || ( (BOOST_VERSION / 100) % 1000 ) >= 35
            #ifndef CAVITY_HAS_HARDWARE_CONCURRENCY_FUNCTION
                #define CAVITY_HAS_HARDWARE_CONCURRENCY_FUNCTION
            #endif
        #endif
    #endif

#endif //ifdef CAVITY_BUILD_WITH_BOOST

//for MSVC++'s annoying macro nonsense
#ifndef NOMINMAX
    #define NOMINMAX
#endif

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <ctime>
#include <cassert>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
#include "dubbstream.hpp"

typedef unsigned int uword;  //sizeof(uword) must be 4 (bitmap format specification)
typedef uword color;
extern const std::size_t & bits_per_char;
extern const long double Pi;
extern dubbstream output;

////////////////////////////////////////////////////
//begin macro magic:
//A quick way to hide the common practice of printing the name of some operation followed by its value, for debugging.
#define THE_DEBUG_STREAM output
#ifndef NDEBUG
    #define PRINT_TO_DEBUG_STREAM( x ) { (THE_DEBUG_STREAM) << "{ " << (#x) << " }: " << (x) << '\n'; }
#else
    #define PRINT_TO_DEBUG_STREAM( x ) {(x);}
#endif

#define printdb PRINT_TO_DEBUG_STREAM
//end macro magic
/////////////////////////////////////////////////////

namespace
{
	inline std::string DateAndTime()
	{
	    using namespace std;
	    time_t t;
	    time(&t);
	    return ctime(&t);
	}
}

template<typename T>
struct square
{
    T operator()(T & arg) { return arg*arg; }
};

template<typename T>
struct identity
{
    T & operator()(T & arg) { return arg; }
};

#endif
